package com.gzhryc.net_marketing.cloud.goods.dao.db;

import com.gzhryc.common.NumberTools;
import com.gzhryc.jdbc.annotaion.Column;
import com.gzhryc.jdbc.annotaion.Id;
import com.gzhryc.jdbc.annotaion.Table;
import com.gzhryc.net_marketing.core.enums.EGoodsClassify;
import com.gzhryc.net_marketing.core.enums.EGoodsState;
import org.apache.commons.lang3.StringUtils;

import java.util.Date;

@Table(name="cloud_goods")
public class CloudGoods {

    @Id(auto = false)
    @Column
    protected String id;

    @Column(name = "supplier_id")
    protected Long supplierId;

    @Column(name = "supplier_name",length = 32,note="供应商名称，冗余字段")
    protected String supplierName;

    @Column(notNull = true,length = 64,note = "商品名称")
    protected String name;

    @Column(name="classify",notNull = true,defVal = "1",note = "商品类型，1：实物，2：虚拟")
    protected Integer classify;

    @Column(name="type_codes",length = 255)
    protected String typeCodes;

    @Column(name="type_names",length = 255)
    protected String typeNames;

    @Column(name="thumbnail_img",length = 128,note="缩略图")
    protected String thumbnailImg;

    @Column(length = 2048)
    protected String imgs;

    @Column(name="detail_imgs",length = 2048,note="详情图")
    protected String detailImgs;

    @Column(length = 255, note = "标签集")
    protected String labels;

    @Column(name = "pay_money",notNull = true,defVal = "0",note = "零售价格")
    protected Integer payMoney;

    @Column
    protected Integer priority; // 优先级

    @Column
    protected Integer state;

    @Column(name = "update_date", autoUpdateTime = true)
    protected Date updateDate;

    @Column(name = "create_date")
    protected Date createDate;

    private String[] imgPaths;
    private String[] detailImgPaths;

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public Integer getClassify() {
        return classify;
    }

    public void setClassify(Integer classify) {
        this.classify = classify;
    }

    public String getTypeCodes() {
        return typeCodes;
    }

    public void setTypeCodes(String typeCodes) {
        this.typeCodes = typeCodes;
    }

    public String getTypeNames() {
        return typeNames;
    }

    public void setTypeNames(String typeNames) {
        this.typeNames = typeNames;
    }

    public String getThumbnailImg() {
        return thumbnailImg;
    }

    public void setThumbnailImg(String thumbnailImg) {
        this.thumbnailImg = thumbnailImg;
    }

    public String getImgs() {
        return imgs;
    }

    public void setImgs(String imgs) {
        this.imgs = imgs;
    }

    public String getDetailImgs() {
        return detailImgs;
    }

    public void setDetailImgs(String detailImgs) {
        this.detailImgs = detailImgs;
    }

    public String getLabels() {
        return labels;
    }

    public void setLabels(String labels) {
        this.labels = labels;
    }

    public Long getSupplierId() {
        return supplierId;
    }

    public void setSupplierId(Long supplierId) {
        this.supplierId = supplierId;
    }

    public String getSupplierName() {
        return supplierName;
    }

    public void setSupplierName(String supplierName) {
        this.supplierName = supplierName;
    }

    public Integer getPayMoney() {
        return payMoney;
    }

    public void setPayMoney(Integer payMoney) {
        this.payMoney = payMoney;
    }

    public Integer getPriority() {
        return priority;
    }

    public void setPriority(Integer priority) {
        this.priority = priority;
    }

    public Integer getState() {
        return state;
    }

    public void setState(Integer state) {
        this.state = state;
    }

    public Date getUpdateDate() {
        return updateDate;
    }

    public void setUpdateDate(Date updateDate) {
        this.updateDate = updateDate;
    }

    public Date getCreateDate() {
        return createDate;
    }

    public void setCreateDate(Date createDate) {
        this.createDate = createDate;
    }

    public String getStateName(){
        return EGoodsState.note(this.state);
    }

    public String getPayMoneyStr(){
        return NumberTools.getMoneyStr(this.payMoney);
    }

    public String getClassifyName(){
        return EGoodsClassify.note(this.classify);
    }

    public String[] getImgPaths(){
        if(imgPaths == null && StringUtils.isNotBlank(this.imgs)){
            imgPaths = this.imgs.split("\\|");
        }
        return imgPaths;
    }

    public String[] getDetailImgPaths(){
        if(detailImgPaths == null && StringUtils.isNotBlank(this.getDetailImgs())){
            detailImgPaths = this.getDetailImgs().split("\\|");
        }
        return detailImgPaths;
    }

    public void setImgPaths(String[] imgPaths) {
        this.imgPaths = imgPaths;
    }

    public void setDetailImgPaths(String[] detailImgPaths) {
        this.detailImgPaths = detailImgPaths;
    }
}
